package com.freight.user.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.freight.core.common.utils.PageUtil;
import com.freight.core.common.utils.ResultUtil;
import com.freight.core.common.vo.PageVo;
import com.freight.core.common.vo.Result;
import com.freight.user.dto.DriverDto;
import com.freight.user.service.IDriverVoService;
import com.freight.user.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author huyingtai
 */
@Slf4j
@RestController
@Api(description = "司机详情信息管理接口")
@RequestMapping("/freight/driverInfoVo")
@Transactional
public class UserDriverVoController {

    @Autowired
    private IDriverVoService iDriverVoService;


    @RequestMapping(value = "/getCarrierDriverVo", method = RequestMethod.POST)
    @ApiOperation(value = "根据用户id获取司机信息")
    public Result<CarrierDriverVo> getCarrierDriverVo(Long userId) {
        CarrierDriverVo carrierDriverVo = iDriverVoService.getCarrierDriverVo(userId);
        return new ResultUtil<CarrierDriverVo>().setData(carrierDriverVo);
    }

    @RequestMapping(value = "/complaintList", method = RequestMethod.POST)
    @ApiOperation(value = "司机 --- 根据用户id获取获取投诉信息")
    public Result<IPage<MsgConsultingListVo>> complaintList(PageVo page, Long userId) {
        IPage<MsgConsultingListVo> data = iDriverVoService.complaintList(PageUtil.initMpPage(page),userId);
        return new ResultUtil<IPage<MsgConsultingListVo>>().setData(data);
    }


    @RequestMapping(value = "/getDriverInformation", method = RequestMethod.POST)
    @ApiOperation(value = "根据用户id获取司机个人证件信息")
    public Result<DriverInformationVo> getDriverInformation(Long userId) {
        DriverInformationVo driverInformationVo = iDriverVoService.getDriverInformation(userId);
        return new ResultUtil<DriverInformationVo>().setData(driverInformationVo);
    }

    @RequestMapping(value = "/getManageUserIdUser", method = RequestMethod.GET)
    @ApiOperation(value = "获取车辆管理人列表")
    public Result<List<ManageUserVo>> getManageUserIdUser(String mobile) {
        List<ManageUserVo> manageUserVos = iDriverVoService.getManageUserIdUser(mobile);
        return new ResultUtil<List<ManageUserVo>>().setData(manageUserVos);
    }

    @RequestMapping(value = "/getAppointDriverInfoByUserId", method = RequestMethod.GET)
    @ApiOperation(value = "获取单个订单司机信息")
    public Result<AppointDriverInfoVo> getAppointDriverInfoByUserId(@RequestParam Long userId) {
        AppointDriverInfoVo driverInfoVo = iDriverVoService.getAppointDriverInfoByUserId(userId);
        return new ResultUtil<AppointDriverInfoVo>().setData(driverInfoVo);
    }

    @RequestMapping(value = "/getAppointDriverInfoByUserIds", method = RequestMethod.GET)
    @ApiOperation(value = "获取多个订单司机信息")
    public Result<List<AppointDriverInfoVo>> getAppointDriverInfoByUserIds(@RequestParam Long[] userId) {
        List<AppointDriverInfoVo> driverInfoVo = iDriverVoService.getAppointDriverInfoByUserIds(userId);
        return new ResultUtil<List<AppointDriverInfoVo>>().setData(driverInfoVo);
    }

    @RequestMapping(value = "/getDriverInfo", method = RequestMethod.GET)
    @ApiOperation(value = "平台端 --- 获取司机的信息")
    public Result<IPage<DriverDetailInfoVo>> getDriverInfo(PageVo page, DriverDto driverDto) {
        Page<DriverDetailInfoVo> driverInfoVos = iDriverVoService.getDriverInfo(PageUtil.initMpPage(page),driverDto);
        return new ResultUtil<IPage<DriverDetailInfoVo>>().setData(driverInfoVos);
    }

    @RequestMapping(value = "/getCompanyDriverInfo", method = RequestMethod.GET)
    @ApiOperation(value = "货主端 --- 获取司机的信息")
    public Result<IPage<DriverDetailInfoVo>> getCompanyDriverInfo(PageVo page, DriverDto driverDto) {
        Page<DriverDetailInfoVo> driverInfoVos = iDriverVoService.getCompanyDriverInfo(PageUtil.initMpPage(page),driverDto);
        return new ResultUtil<IPage<DriverDetailInfoVo>>().setData(driverInfoVos);
    }

    @RequestMapping(value = "/getDriverInfoByUserId", method = RequestMethod.GET)
    @ApiOperation(value = "获取司机基本信息")
    public Result<DriverInfoVo> getDriverInfoByUserIds(Long userId) {
        DriverInfoVo driverInfoVo = iDriverVoService.getDriverInfoByUserId(userId);
        return new ResultUtil<DriverInfoVo>().setData(driverInfoVo);
    }


}
